package com.senken.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.senken.base.BaseController;
import com.senken.entity.SkRole;
import com.senken.service.ISkRoleService;
import com.senken.service.ISkUserRoleService;

@Controller
@RequestMapping("/role")
public class RoleController extends BaseController{

	@Autowired
	private ISkRoleService roleService;
	@Autowired
	private ISkUserRoleService userroleservice;
	
	@RequestMapping("/findAll")
	@ResponseBody
	public List<SkRole> findAll(){
		return roleService.findAllRole();
	}
	
	@RequestMapping("/findBystate")
	@ResponseBody
	public List<SkRole> findBystate(int state){
		return roleService.findroleByState(state);
	}
	
	@RequestMapping("/updaterole")
	@ResponseBody
	public Object updaterole(int userid,int roleid){
		 if(userroleservice.update(userid, roleid)){
			 return renderSuccess();
		 }
		 return renderError("系统错误，无法更改");
	} 
}
